<!DOCTYPE html>
<html lang="zh-cn">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>浏览器窗体尺寸</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        div {
            margin: 0 auto;
            margin-top: 150px;
            width: 300px;
            height: 300px;
            background-color: #fedcba;
            text-align: center;
        }
    </style>
</head>

<body>
    <div></div>
</body>

</html>
<script>
    window.addEventListener('DOMContentLoaded', function(e) {
        let div = window.document.querySelector('div');
        window.addEventListener('resize', function(e) {
            let array = new Array();
            array.push('内部宽度:' + window.innerWidth + '>>>内部宽度:' + window.innerHeight);
            array.push('<br>');
            array.push('窗体宽度:' + window.outerWidth + '>>>窗体宽度:' + window.outerHeight);
            div.innerHTML = array.join('');
        });

    });
</script>